package com.client.base;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.client.base.log.Impl.Loger;
import com.client.base.log.Impl.LogerFactory;

public abstract class BaseAction extends Action implements ClientAction{
	
	protected static Loger loger = LogerFactory.getLoger(BaseAction.class);
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		loger.info(" starting process the request["+request.getRequestURL()+"] ");
		
		try {
			String forwardName = process((BaseForm)form,request,response);
			request.setAttribute("reqForm", form);
			
			if( !"".equals(forwardName) 
					&& forwardName != null )
				return mapping.findForward(forwardName);
			
		}
		catch( Exception e ){
			e.printStackTrace();
			loger.error(" some unknown exception occured during processing the" +
					" request["+request.getRequestURL()+"] ",e);
		}
		
		return super.execute(mapping, form, request, response);
		
	}


}
